<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        #box{
            width: 150px;
            height: 150px;
            background-color: yellowgreen;
            position: absolute;
            left: 0;
            top: 100px;
        }

        #box1{
            width: 150px;
            height: 150px;
            background-color: red;
            position: absolute;
            left: 200px;
            top: 300px;
        }
    </style>
</head>
<body>
    <button id="btn">往右走</button>
    <button id="btn1">往左走</button>
    <div id="box"></div>
    <div id="box1"></div>
<script src="js/myFunc.js"></script>
<script>
    // 动画的基本原理是：盒子的offsetLeft + 步长
    window.onload = function () {
        $("btn").onmousedown = function () {
            constant($("box"), 800, 20);
            constant($("box1"), 600, -20);
        };

        $("btn1").onmousedown = function () {
            constant($("box"), -200, 20);
            constant($("box1"), 500, 5);
        }
    };

</script>
</body>
</html>